﻿using Engine;
using Game;
namespace Mekiasm
{
    public class TransmitWidget : BaseEnergyWidget
    {
        public ComponentEnergyMachine Component;
        public MutiBlockCheck.TranmitResult TranmitResult;
        public LabelWidget labelWidget = new LabelWidget() { FontScale = 0.7f, Color = Color.Green };
        public TransmitWidget(ComponentTransmitMachine component, MutiBlockCheck.TranmitResult tranmit, ComponentMiner miner) : base(miner)
        {
            Component = component;
            TranmitResult = tranmit;
            if (TranmitResult.Connected)
            {
                labelWidget.Text = "已连接";
                labelWidget.Color = Color.Green;
            }
            else
            {
                labelWidget.Color = Color.Red;
                labelWidget.Text = "未连接";
            }
            CanvasMain.Children.Add(labelWidget);
            setTitle("传送门");
        }
        public override void Update()
        {
            SetLeftBottomMoreInfo($"消耗: {ILibrary.FormatPower(TransmitMachine.TransmitUse)} \n当前:{ILibrary.FormatPower(Component.Power)}\n最大:{ILibrary.FormatPower(1024 * 1024 * 1024)}");
            SetPowerProgress(Component.Power / (float)Component.MaxPower);
        }

    }

}